import request from '@/utils/request'
import { API_CONFIG } from '@/config'

// 获取角色列表
export function getRoleList(params) {
    return request({
        url: API_CONFIG.ROLE_LIST,
        method: 'get',
        params
    })
}

// 新增角色
export function addRole(data) {
    return request({
        url: API_CONFIG.ROLE_ADD,
        method: 'post',
        data
    })
}

// 更新角色
export function updateRole(data) {
    return request({
        url: API_CONFIG.ROLE_UPDATE,
        method: 'post',
        data
    })
}

// 删除角色
export function deleteRole(id) {
    return request({
        url: `${API_CONFIG.ROLE_DELETE}/${id}`,
        method: 'delete'
    })
}

// 更新角色状态
export function updateRoleStatus(id, status) {
    return request({
        url: API_CONFIG.ROLE_UPDATE_STATUS,
        method: 'put',
        data: { id, status }
    })
}

// 获取角色权限
export function getRolePermissions(roleId) {
    return request({
        url: `${API_CONFIG.ROLE_PERMISSIONS}/${roleId}`,
        method: 'get'
    })
}

// 更新角色权限
export function updateRolePermissions(roleId, permissions) {
    return request({
        url: API_CONFIG.ROLE_UPDATE_PERMISSIONS,
        method: 'put',
        data: { roleId, permissions }
    })
}

// 根据角色ID获取菜单
export function getRoleMenus(roleId) {
    return request({
        url: `${API_CONFIG.ROLE_MENUS}/${roleId}`,
        method: 'get'
    })
} 